Welcome to Solarduino , A blog about DIY Solar PV and Arduino projects

How to combine 2 PZEM meters together using Blynk App for NodeMCU

PZEM meters are Energy Meters from Peacefair. Peacefair is a very famous Chinese brand with good quality and price that specialize in Metering products. They came out with many types of Energy Meters. Most user friendly plug and play meter would be the meter with the LCD display attached. They are cheap and without any settings. It categorized by AC and DC meter with different current measurement rating from 10A up to few hundred amperes.

 

Peacefair PZEM-021 Energy meter is an compact AC energy meter that measures Voltage, Current, Power and Energy. Peacefair has a lot of model to measure different current requirement from 20A up to 100A. You can get it at our affiliate link here !!!   

Peacefair PZEM-051 Energy meter is an compact DC energy meter that measures Voltage, Current, Power and Energy. Peacefair has a lot of model to measure different current requirement from 20A up to 100A. You can get it at our affiliate link here !!!   

For someone would like to have a full control especially for DIY, they prefer using PZEM series Energy Meter which have more flexibility and customization such as to use the measurable data for further application, adding them to an Arduino project, modify the values or even upload to the web interface for online and remote monitoring. The meters do not have Display on it, that is why it is cheap to own.

It consists DC Energy Meter (PZEM-017) which can measure DC voltage up to 300V and current up to 300A subject to the shunt resistor selection. As for AC Energy Meter (PZEM-014) which can measure AC current up to 10A for direct connection while (PZEM-016) can measure AC current up to 100A using current transformer.

All of the PZEM series Energy Meters have a built in RS485 communication interface using Modbus-RTU protocol similar to most industrial devices. By default, the supplier will provide buyer a software so that the measured values can be displayed on your PC using UART to RS485 converter. You can download the software here (for AC) and here (for DC)!!!

PZEM-014 or PZEM-016 AC Energy Meter

PZEM-014 and PZEM-016 are the AC Energy Acquisition devices that measure Voltage, Current, Power, Energy, Frequency, and Power Factor. You can read the data via come-along RS485 software in PC.  Kindly purchase from our affiliate link here!!!

PZEM-017 DC Energy Module

PZEM-017 is a DC Energy Module that can support up to 300Vdc and the current measurement is subject to external shunt installed. It can be up to 50A, 100A, 200A and 300A. You can get it at a very competitive price at our affiliate link here !!!

Warning ! You may now dealing with high voltage and high power source ! We assumed that you have the basic electrical knowledge and know what you are dealing with. You may need guidance from experienced guys if you are new to electrical work. Safety and Precaution must be always have in mind. We shall not be responsible for anything happening to you.

Since this Energy Measurement Device uses RS485 communication, in order for micro-controller such as Arduino boards and NodeMCU to read data from the Energy Module, we need a converter module that can convert RS485 to Serial. We need a UART TTL to RS485 converter module. Generally there are 2 types of RS485 converter module 1) only 2 communication output pins named Tx and Rx and 2) 4 communication output pins named DI, DE, RE and RO). In this example we are using the 4 pins module (Type 2).

MAX485 UART TTL RS485 converter

This is a module that converts between RS485 communication and Serial (UART TTL) communication. This module enables Arduino to communicate, read or provide command to devices that using RS485 communication. Quickly grab this module at our affiliate link here !!!

This blog will be focusing on how to use one nodeMCU to read more than 1 PZEM series Energy Meters. If you want to use only one PZEM meter, perhaps links below is more suitable for you:

  1. Using PC / Arduino UNO for PZEM-017 DC Energy Meter
  2. Using PC / Arduino UNO for PZEM-014/016 Energy Meter
  3. Using PZEM-017 DC Meter online monitoring using NodeMCU and Blynk App.
  4. Using PZEM-014/016 AC Meter online monitoring using NodeMCU and Blynk App.

Components Requirement :

  • 1 x Node MCU board
  • 1 x Node MCU base
  • 1 x Serial to RS485 converter module
  • 2 x PZEM meters (Any combination of DC / AC)
  • 1 x 12V power Adaptor
  • 1 x set of Dupond Wires

NodeMCU micro-controller

The NodeMCU micro-controller is similar to Arduino micro-controller board. It is compatible with Arduino IDE software and is built-in with the ESP8266 module which can be connected to the internet. You can grab some at our affiliate link here !!!  

Node MCU Micro controller Base

The based below the Node MCU can provide more flexibility on the connection ports to support more sensors. Besides, it also has 12V input port and able to provide 5V power supply to support the sensors. Support us by purchase it from our affiliate link here !!!

Hardware Connection

You are dealing with Main Supply Power, any exposed conductors need to be isolated and fused. Turn the measurement power source OFF during hardware connection. I recommend to use ferrule lug for terminal tight connection and prevent stranded conductor accidentally touching adjacent cable line which might cause short circuit and fire risk. Furthermore, no conductive materials are placed around the workplace and use non-metallic enclosure or project box.

If you get an energy meter with current transformer (CT), make sure to get the Split-Core type which can open and hookup it easily. On the right side of the meter is the High Power Side, so any direct connection need to be protected with over-current device such as fuse. The fuse rating must be lower than the cable current carrying capacity to avoid cable burn and fire risk. It is highly recommend to use ferrule lugs at cable terminals. For detailed wiring on the measurement side, kindly refer to my older blog page.

Wiring of Serial to RS485 Converter Summary :

  1. A to A terminal of Energy Module (parallel with other Energy Module)
  2. B to B terminal of Energy Module (parallel with other Energy Module)
  3. Vcc to 5V positive
  4. Gnd to 5V ground 
  5. RO to D2 of Node MCU
  6. DI to D3 of Node MCU
  7. RE to pin D1 of Node MCU
  8. DE to pin D0 of Node MCU

Each PZEM must have different address so that the NodeMCU knows which one to communicate. The Energy Meter must set 1 by 1. In my video example, I set the DC meter as address 0x01 (hex code for address 1) while AC meter as address 0x02 (hex code for address 2). If you want to connect more meters, you can just duplicate the codes for other meters but you need to set the address for each meter differently. 

Make sure the Energy Meters only connected to RS485 converter after the Arduino Code has successfully upload to the NodeMCU or else it might has the chance to have same address between the two meters; during address setting, the command is sent broadcast so that all meters in connection will receive the same command.

Blynk App – The Online Data Monitoring Platform

Blynk is a user friendly platform that provide web interface for data display. It provide smart phone app for easy setup and monitoring. In the app, there are a lot of Widget Boxes which suits a lot of measurement data. However, if you want to use the Widgets, it will consume energies based on the Widget types, similar to online games that you may need to top up the energy when you require more widgets. Upon creating an account, there will be some energy which should be enough for small project.

Download Bylnk App on Google Play

Download Bylnk App on App Store

Ferrule Lugs and Crimper Set

Ferrule lugs are used at terminals for tight and secure connection. Besides, it also prevent stranded cables accidentally touching adjacent power line that may cause short circuit. Grab 1 at our affiliate link here !!!

Software Step by Step Guideline

The software part will be divided into 2 parts: 1) the smart phone web interface Blynk App and the 2) programming part using Arduino IDE Software.

On phone 

  1. Download Blynk App on your smart phone (Google Play / AppStore).
  2. Open and create an Account on Blynk App.
  3. Add New Project  (see below section)
  4. Blynk will send a Auth Token to your email specifically for this project.
  5. At your project main page, swap to the left to open Widget Box.
  6. Add Widget based on your desire: 

Widget settings (2 AC Energy Meters): 

Virtual pin V0 = Meter 1 – AC Voltage Value

Virtual pin V1 = Meter 1 – AC Current Value

Virtual pin V2 = Meter 1 – AC Power Value

Virtual pin V3 = Meter 1 – AC Energy Value

Virtual pin V4 = Meter 1 – Power Factor Value

Virtual pin V5 = Meter 1 – Frequency Value

Virtual pin V6 = Meter 1 – Energy Reset Button

Virtual pin V7 = Meter 2 – AC Voltage Value

Virtual pin V8 = Meter 2 – AC Current Value

Virtual pin V9 = Meter 2 – AC Power Value

Virtual pin V10 = Meter 2 – AC Energy Value

Virtual pin V11 = Meter 2 – Power Factor Value

Virtual pin V12 = Meter 2 – Frequency Value

Virtual pin V13 = Meter 2 – Energy Reset Button

 

Widget settings (2 DC Energy Meters): 

Virtual pin V0 = Meter 1 – DC Voltage Value

Virtual pin V1 = Meter 1 – DC Current Value

Virtual pin V2 = Meter 1 – DC Power Value

Virtual pin V3 = Meter 1 – DC Energy Value

Virtual pin V4 = Meter 1 – Energy Reset Button

Virtual pin V5 = Meter 2 – DC Voltage Value

Virtual pin V6 = Meter 2 – DC Current Value

Virtual pin V7 = Meter 2 – DC Power Value

Virtual pin V8 = Meter 2 – DC Energy Value 

Virtual pin V9 = Meter 2 – Energy Reset Button

 

Widget settings (1 AC & 1 DC Energy Meters): 

Virtual pin V0 = Meter 1 – DC Voltage Value

Virtual pin V1 = Meter 1 – DC Current Value

Virtual pin V2 = Meter 1 – DC Power Value

Virtual pin V3 = Meter 1 – DC Energy Value

Virtual pin V4 = Meter 1 – Energy Reset Button

Virtual pin V5 = Meter 2 – AC Voltage Value

Virtual pin V6 = Meter 2 – AC Current Value

Virtual pin V7 = Meter 2 – AC Power Value

Virtual pin V8 = Meter 2 – AC Energy Value

Virtual pin V9 = Meter 2 – Power Factor Value

Virtual pin V10 = Meter 2- Frequency Value

Virtual pin V11 = Meter 2 – Energy Reset Button

 

 

On Laptop / PC

  1. Install Arduino IDE Programming Software (If you do not have the software, click here to download)
  2. Install Node MCU Board Manager for using Node MCU in Arduino IDE Programming Software (see below section)
  3. Install Node MCU ESP8266 Library for using Wifi codes in Node MCU (see below section)
  4. Install Modified Modbus Library for using Modbus communication codes in Node MCU (see below section)
  5. Install ESP Software Serial Library for using virtual Serial Ports (see below section)
  6. Install Blynk Library for enable the Node MCU using Blynk server (see below section)
  7. Copy Auth Token from the email, note down the Wifi name & password.
  8. Upload the code to Node MCU Board. 

Install Node MCU Board Manager 

If this is the first time you are dealing with NodeMCU, you need to add NodeMCU board manager file into the IDE software so that the software can support the Node MCU board. To add the Support File, open Arduino IDE Software, go to files>preferences>Additional Boards Manager URLs, paste this link http://arduino.esp8266.com/stable/package_esp8266com_index.json to the black space and click OK. Go to Tool > Board > make sure the board is showing NodeMCU 1.0 (ESP-12E module).

Terminals Crimping Plier Set

This is a crimping tool with interchangeable jaw for crimping many types of terminals. It is a must have for DIY electronic and electrical for professional installation work. You may choose at out affiliate link here !!!

Install ESP8266 Wifi Library

If this is the first time you are dealing with Wifi programming, this ESP8266 Wifi Library file is needed to be installed to the Arduino IDE Software so that it can understand the programming function. Go to Tools > Boards > Boards Manager and download the ESP8266 library by ESP8266 Community

Install Modified Modbus Master Library

If this is the first time you are dealing with modbus communication, this Modified Modbus Master Library file is needed to be installed to the Arduino IDE Software so that it can understand the programming function. If you have installed the original  ModbusMaster.h library from library management, kindly look into the folder and delete it or it will clash with this library

The Modified Modbus Master Library I get it from EvertDekker.com and I have uploaded the zip file here so that you can download and install it. Go to Sketch > Include Library > Add.ZIP Library…. and locate the zip file. Make sure you download it to your PC first (preferably download at desktop)

Install ESP Software Serial Library

If this is the first time you use the Software Serial to add Serial Port, you may need to install and download the ESPSoftwareSerial Library in the manage library section. This Library is different with the standard Software Serial, so be sure to install the correct library. Go to Tools > Manage Libraries … and type “ESPSoftwareSerial”. Download from Peter Lerup.

Install Blynk Library

If this is the first time you are dealing with Blynk server, this Blynk Library file is needed to be installed to the Arduino IDE Software so that it can understand the programming function. Go to Tools > Boards > Boards Manager and download the Blynk library by Volodymyr Shymanskyy

Arduino Starter Kit

It is a complete set which include most of the components you need to start Arduino Projects. Kindly support us by grabbing one set at our affiliate link here !!!

The smart phone Blynk app and Arduino IDE software are two independent parties. As long as you do it right, the Node MCU board should be able to send toe data to the Blynk server so that you can see the values from your smart phone. One of the advantage of using Blynk is that the Blynk server can allow for data storage so that you can trace or download previous record. All the hard part have been done, all you need is just following the instruction and it should work well. You can customize your web interface at Blynk App. Below is one of the example how it would look like.

Before we end, we would like to give gratitude to you for taking the time to read the post. We would need readers like you to support us in order to keep growing. You can support us in the following ways :

Donate & Fund Raising

If you like my work, please send me a donation to encourage me to do more. Thanks

Aliexpress Affiliate

We are the member of Aliexpress affiliate marketing. Do support us by clicking the affiliate product links if you do wish to purchase them.

Like and Share

If you like our post, we need your support to like and share our posts or videos so that it can reach more and more people like you !!

Set Address.ino
DC & AC Energy Meter.ino
2 x AC Energy Meter.ino
2 X DC Energy Meter.ino